package com.scd.boot.util;

import cn.hutool.core.net.URLEncodeUtil;
import jakarta.servlet.http.HttpServletRequest;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class HttpUtil {

    /**
     * 判断是否文件上传
     * @param request 请求头
     * @return true or false
     */
    public static boolean isMultipartContent(HttpServletRequest request) {
        String contentType = request.getContentType();
        return (contentType != null && contentType.toLowerCase().startsWith("multipart/"));
    }

    /**
     * 编码字符串
     * @param inputStr 输入字符串
     * @return 返回值
     */
    public static String encodeStr(String inputStr) {
        return URLEncoder.encode(inputStr, StandardCharsets.UTF_8);
    }
}
